package com.lcm.test.designpatterntest.Singleton;

import lombok.extern.slf4j.Slf4j;

/**
 * @description:
 * @author: lcm
 * @create: 2020-03-11 15:40
 **/
@Slf4j
public class EnumSingleton {

    public int value=1;

    private enum InnerEnum{
        singleton;

        EnumSingleton enumSingleton;

        InnerEnum(){
            enumSingleton=new EnumSingleton();
            log.info("枚举单例初始化成功！");
        }
    }

    public static EnumSingleton getSingleton(){
        return InnerEnum.singleton.enumSingleton;
    }

    public static void main(String[] args){
        System.out.println("懒加载单例，只有再真正调用的时候，才会初始化！");
        System.out.println(EnumSingleton.getSingleton().value);
    }

}
